package jeye.client.buffer;

import java.io.InputStream;
import java.util.Vector;

public class FrameBuffer {

	private static final long serialVersionUID = -8945251171583826677L;
	
	private Vector buffer;
	
	public FrameBuffer() {
		buffer = new Vector();
	}
	
	public synchronized boolean addFrame(InputStream stream) {
		int size = buffer.size();
		
		buffer.addElement(stream);
		
		return size < buffer.size();
	}
	
	public synchronized InputStream getFrame() {
		if(buffer.size() > 0) {
			InputStream stream = (InputStream)buffer.firstElement();
			
			buffer.removeElement(stream);
			
			return stream;
		}
		return null;
	}
	
}
